<template>
	<view class="list-box">
		<!-- 我的赠送或我的领取 商品 -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type<3&&current==0">
			<view class="t-top">
				<img :src="item.pic||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.prodName||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
							<text v-if="item.price">{{item.units?`/${item.units}`:''}}</text>
							<text v-else>{{item.units?item.units:''}}</text>
						</view>
						<view class="t-money-rt">
							x{{ item.num||'' }}
						</view>
					</view>
					<view class="t-name">
						收货人：{{ item.takePeople||'' }}
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的赠送 代金券 -->
		<view class="right-item right-item2" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==1&&current==1">
			<img class="t-status"
				:src="item.useStatus==0&&item.userOpenId==null?couponStatusImgStatus[0]:item.useStatus==0&&item.userOpenId?couponStatusImgStatus[1]:couponStatusImgStatus[2]"
				alt="">

			<view class="t-top">
				<view class="t-info">
					<view class="t-title">
						{{ item.name ||''}}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的领取 代金券 -->
		<view class="right-item right-item2" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==2&&current==1">
			<img class="t-status" :src="item.useStatus==0?couponStatusImgStatus[0]:couponStatusImgStatus[2]" alt="">
			<view class="t-top">
				<view class="t-info">
					<view class="t-title">
						{{ item.name ||''}}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的赠送 大礼包 -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==1&&current==2">
			<img class="t-status"
				:src="item.useStatus==0&&item.userOpenId==null?couponStatusImgStatus[0]:item.useStatus==0&&item.userOpenId?couponStatusImgStatus[1]:couponStatusImgStatus[2]"
				alt="">
			<view class="t-top">
				<img :src="item.image||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.name||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
					<view class="t-name t-name-time">
						{{ item.createTime ||''}}
					</view>
				</view>
			</view>
		</view>
		<!-- 我的领取 大礼包 -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)"
			v-show="type==2&&current==2">
			<img class="t-status" :src="item.useStatus==0?couponStatusImgStatus[0]:couponStatusImgStatus[2]" alt="">
			<view class="t-top">
				<img :src="item.image||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.name||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
						</view>
					</view>
					<view class="t-name t-name-time">
						{{ item.createTime ||''}}
					</view>
				</view>
			</view>
		</view>

		<!-- 我的售出  -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)" v-show="type==3">
			<view class="t-top">
				<img :src="item.pic||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.prodName||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
							<text v-if="item.price">{{item.units?`/${item.units}`:''}}</text>
							<text v-else>{{item.units?`${item.units}`:''}}</text>
						</view>
						<view class="t-money-rt">
							x{{ item.num||'' }}
						</view>
					</view>
					<view class="t-name">
						收货人：{{ item.takePeople||'' }}
					</view>
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>
		<!-- 我的购买  -->
		<view class="right-item" v-for="(item, index) in dataList" :key="index" @click="regLink(item)" v-show="type==4">
			<view class="t-top">
				<img :src="item.pic||''" alt="" />
				<view class="t-info">
					<view class="t-title">
						{{ item.prodName||'' }}
					</view>
					<view class="t-money">
						<view class="t-money-lt">
							{{item.price?`￥${item.price}`:''}}
							<text v-if="item.price">{{item.units?`/${item.units}`:''}}</text>
							<text v-else>{{item.units?`${item.units}`:''}}</text>
						</view>
						<view class="t-money-rt">
							x{{ item.num||'' }}
						</view>
					</view>
					<!-- <view class="t-name">
						收货人：{{ item.name }}
					</view> -->
				</view>
			</view>
			<view class="t-time"> {{item.createTime||''}} </view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				//优惠券领取状态照片
				couponStatusImgStatus: [
					'https://file.casugn.com/storecompcard//puMCCZBjY0NFf20e585cd67837d1fb0b4d169c695c66_1705286971097.png',
					'https://file.casugn.com/storecompcard//rFciu4kTExbReea3b8a18ade5f13f1da6c83db3a4753_1705287241061.png',
					'https://file.casugn.com/storecompcard//a4bJbKghXzBh202ed71f60e1b134eb21bb644774c316_1705287286207.png'
				],
			};
		},
		props: {
			// dataList: Array,
			// type: Number,
			// current: Number,

			dataList: {
				type: Array,
				required: true,
				default: () => [],
			},
			type: {
				type: Number,
				required: true,
				default: 0,
			},
			current: {
				type: Number,
				required: true,
				default: 0,
			},
		},
		onShow() {
			console.log(dataList)
		},
		methods: {
			regLink(e) {
				console.log(e, 'index');
				console.log(this.type, '左侧点击')
				console.log(this.current, '右侧点击')

				// 我的赠送 商品跳转详情
				if (this.type == 1 && this.current == 0) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/sendDetail?id=${e.id}&type=${this.type}&current=${this.current}`
					})
				}
				// 我的领取 商品跳转详情
				if (this.type == 2 && this.current == 0) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/sendDetail?id=${e.id}&type=${this.type}&current=${this.current}`
					})
				}
				// 我的赠送 代金券跳转详情
				if (this.type == 1 && this.current == 1) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}
				// 我的领取 代金券跳转详情
				if (this.type == 2 && this.current == 1) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}



				// 我的赠送 大礼包跳转详情
				if (this.type == 1 && this.current == 2) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}
				// 我的领取 大礼包跳转详情
				if (this.type == 2 && this.current == 2) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}

				// 我的售出 待发货已发货跳转详情
				if (this.type == 3) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}
				// 我的购买 待发货已发货跳转详情
				if (this.type == 4) {
					uni.navigateTo({
						url: `/pagesMall/myOrder/bigGiftDetail?id=${e.id}&type=${this.type}&current=${this.current}&isCompany=false`
					})
				}




				// const pageNum = getCurrentPages()
				// console.log('navigateTo pageNum: ', pageNum.length)
				// if (pageNum.length > 9) {
				// 	switch (e) {
				// 		case 0:
				// 			uni.redirectTo({
				// 				url: `/pagesMall/mallCenter/mallCenter`
				// 			})
				// 			break;
				// 		case 1:
				// 			uni.redirectTo({
				// 				url: `/pagesMall/myShop/myShop`
				// 			})
				// 			break;
				// 		case 2:
				// 			uni.redirectTo({
				// 				url: `/pagesMall/myOrder/orderList`
				// 			})
				// 			break;
				// 	}

				// } else {
				// 	switch (e) {
				// 		case 0:
				// 			uni.navigateTo({
				// 				url: `/pagesMall/mallCenter/mallCenter`
				// 			})
				// 			break;
				// 		case 1:
				// 			uni.navigateTo({
				// 				url: `/pagesMall/myShop/myShop`
				// 			})
				// 			break;
				// 		case 2:
				// 			uni.navigateTo({
				// 				url: `/pagesMall/myOrder/orderList`
				// 			})
				// 			break;
				// 	}

				// }

			},
		}
	}
</script>

<style scoped lang="scss">
	.list-box {
		// padding-bottom: 146rpx;
		padding-bottom: 20rpx;
		overflow: hidden;
	}

	.right-item {
		width: 446rpx;
		// height: 244rpx;
		background: #ffffff;
		border-radius: 16rpx;
		margin: 0 auto;
		margin-top: 32rpx;
		position: relative;
		padding: 24rpx;

		.t-status {
			position: absolute;
			width: 102rpx;
			height: 102rpx;
			top: 0;
			right: 0;
		}

		.t-top {
			display: flex;

			img {
				width: 160rpx;
				height: 160rpx;
				// vertical-align: middle;
				border-radius: 8rpx;
			}

			.t-info {
				margin-left: 24rpx;

				.t-title {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 600;
					color: #1D2129;
					line-height: 40rpx;
					width: 258rpx;
					overflow: hidden; //盒子超出隐藏
					text-overflow: ellipsis; //超出部分以省略号显示
					white-space: nowrap; //文本强制一行显示,也就是不
				}

				.t-money {
					display: flex;
					justify-content: space-between;
					line-height: 40rpx;
					margin-top: 16rpx;

					.t-money-lt {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 600;
						color: #FF3131;
						line-height: 40rpx;
						height: 40rpx;

						text {
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #FF3131;
							line-height: 34rpx;
						}
					}

					.t-money-rt {
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: #1D2129;
						line-height: 34rpx;
						position: relative;
						top: 6rpx;
					}
				}

				.t-name {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #86909C;
					line-height: 34rpx;
					margin-top: 16rpx;
					width: 258rpx;
					// overflow: hidden; //盒子超出隐藏
					// text-overflow: ellipsis; //超出部分以省略号显示
					// white-space: nowrap; //文本强制一行显示,也就是不

				}

				.t-name-time {
					color: #C9CDD4;
				}
			}
		}

		.t-time {
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #C9CDD4;
			line-height: 34rpx;
			margin-top: 20rpx;
		}

	}

	// 代金券
	.right-item2 {
		position: relative;

		.t-top {
			display: block;

			.t-info {
				margin-left: 0;
				border-bottom: 1rpx dashed #E5E6EB;
				padding-bottom: 24rpx;
			}
		}

	}
</style>